package demo1;

import java.util.Arrays;
import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2024-01-27  21:03
 */
public class Main {
    public static void main(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        int array[] = {1,3,5,8,24,56};

        for(int i = 0; i < array.length; i++) {
            priorityQueue.offer(array[i]);
        }

        int k = 3;
        int ret[] = new int[k];
        for(int j = 0; j < k; j++) {
            ret[j] = priorityQueue.poll();
        }

        System.out.println(Arrays.toString(ret));
    }
}
